Being a dynamically typed language, the Python interpreter only does type checking during runtime. Getting the typing right is important as certain
operations may result in a TypeError
.
Type hints can be used to clarify the expected return type of a function, enabling developers to better document its contract. Applying them
consistently makes the code easier to read and understand.
In addition, type hints allow some development environments to offer better autocompletion and improve the precision of static analysis tools.